package com.example.demo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.example.demo.adapter.MyAdapter;
import com.example.demo.adapter.OneMyAdapter;
import com.example.demo.model.Joke;

import java.util.ArrayList;

public class JokeOne extends AppCompatActivity {

    RecyclerView recyclerViewOnlyone;

    private ArrayList<Joke> jokeslist = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_joke_one);
        init();
        Intent intent=getIntent();
        String joketitle=intent.getStringExtra("joketitle");
        String jokecontent=intent.getStringExtra("jokecontent");
        Joke joke = new Joke(joketitle,jokecontent);
        jokeslist.add(joke);
        recycler();
    }
    private void recycler(){
        //设置布局管理器
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerViewOnlyone.setLayoutManager(layoutManager);
        //设置适配器
        OneMyAdapter adapter = new OneMyAdapter(jokeslist);
        recyclerViewOnlyone.setAdapter(adapter);
    }

    private void init(){
        recyclerViewOnlyone = findViewById(R.id.joke_one_content);


    }

}